home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume25 / kit / part01 next >
Encoding:
Text File  |  1991-12-19  |  57.2 KB  |  2,279 lines

  1. Newsgroups: comp.sources.unix
  2. From: ram@eiffel.com (Raphael Manfredi)
  3. Subject: v25i049: kit - the ultimate mailing kit, Part01/04
  4. Sender: sources-moderator@pa.dec.com
  5. Approved: vixie@pa.dec.com
  6.  
  7. Submitted-By: ram@eiffel.com (Raphael Manfredi)
  8. Posting-Number: Volume 25, Issue 49
  9. Archive-Name: kit/part01
  10.  
  11. [ this is a wrapper for cshar2 that lets you mail arbitrary collections of
  12.   possibly-binary files to someone.  it contains a stripped-down copy of the
  13.   DES implementation from comp.sources.unix Volume 7.            --vix ]
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 1 (of 4)."
  22. # Contents:  MANIFEST Makefile.SH README btoa btoa/Makefile.SH
  23. #   btoa/atob.c btoa/btoa.c btoa/hexdecode.c btoa/hexencode.c des
  24. #   des/Makefile.SH des/README des/des.1 des/des.3 des/descert.c
  25. #   des/getopt.c des/getpass.c des/misc.c des/testdata install.SH kit
  26. #   kit/Makefile.SH kit/minikit man man/Makefile.SH man/atob.SH
  27. #   man/btoa.SH man/mailkit.SH man/unkit.SH patchlevel.h
  28. # Wrapped by vixie@cognition.pa.dec.com on Thu Dec 19 21:18:28 1991
  29. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  30. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  32. else
  33. echo shar: Extracting \"'MANIFEST'\" \(1770 characters\)
  34. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  35. README                     Read it
  36. MANIFEST                   This shipping list
  37. Configure                  Portability tool
  38. Makefile.SH                Main makefile
  39. btoa/Makefile.SH           Makefile for btoa and al.
  40. btoa/atob.c                For ascii to binary decoding
  41. btoa/btoa.c                For binary to ascii encoding
  42. btoa/hexdecode.c           Hex-decoding
  43. btoa/hexencode.c           Hex-encoding
  44. config.h.SH                Produces config.h
  45. des/Makefile.SH            Makefile for des
  46. des/README                 Informations on des
  47. des/des.1                  Manual page for des(1)
  48. des/des.3                  Description of the des functions
  49. des/des.c                  Software DES functions from Phil Karn
  50. des/descert.c              Cerifies the des(1) command
  51. des/getopt.c               Public domain implementaion of getopt()
  52. des/getpass.c              Reads a key from the terminal
  53. des/main.c                 Main file for des
  54. des/misc.c                 Implementations of memset() and memcpy()
  55. des/testdata               A set of tests to certify the des
  56. install.SH                 BSD-like installation script
  57. kit/Makefile.SH            Makefile for scripts
  58. kit/kit.SH                 The main script-shell
  59. kit/mailkit.SH             Mails parts generated by "kit"
  60. kit/minikit                The minikit script for kit extraction
  61. kit/unkit.SH               Reversal of "kit"
  62. man/Makefile.SH            Makefile for manual pages
  63. man/atob.SH                Manual page for "atob"
  64. man/btoa.SH                Manual page for atob/btoa
  65. man/kit.SH                 The manual page for "kit"
  66. man/mailkit.SH             The manual page for "mailkit"
  67. man/unkit.SH               The manual page for "unkit"
  68. patchlevel.h               Current patch level value
  69. END_OF_FILE
  70. if test 1770 -ne `wc -c <'MANIFEST'`; then
  71.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  72. fi
  73. # end of 'MANIFEST'
  74. fi
  75. if test -f 'Makefile.SH' -a "${1}" != "-c" ; then 
  76.   echo shar: Will not clobber existing file \"'Makefile.SH'\"
  77. else
  78. echo shar: Extracting \"'Makefile.SH'\" \(1456 characters\)
  79. sed "s/^X//" >'Makefile.SH' <<'END_OF_FILE'
  80. case $CONFIG in
  81. X'')
  82. X    if test ! -f config.sh; then
  83. X        ln ../config.sh . || \
  84. X        ln ../../config.sh . || \
  85. X        ln ../../../config.sh . || \
  86. X        (echo "Can't find config.sh."; exit 1)
  87. X    fi 2>/dev/null
  88. X    . config.sh
  89. X    ;;
  90. esac
  91. case "$0" in
  92. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  93. esac
  94. echo "Extracting Makefile (with variable substitutions)"
  95. X$spitshell >Makefile <<!GROK!THIS!
  96. X#
  97. X#    Makefile for kit
  98. X#
  99. X
  100. X# $Id: Makefile.SH,v 2.0.1.4 91/12/08 14:53:40 ram Exp $
  101. X#
  102. X# $Log:    Makefile.SH,v $
  103. X# Revision 2.0.1.4  91/12/08  14:53:40  ram
  104. X# patch10: make clobber was not removing cppstdin
  105. X# 
  106. X# Revision 2.0.1.3  91/11/25  12:03:02  ram
  107. X# patch8: this file was stamped with a wrong package name
  108. X# 
  109. X# Revision 2.0.1.2  91/05/27  14:14:19  ram
  110. X# patch5: some dumb make failed on previous makefile
  111. X# 
  112. X# Revision 2.0.1.1  91/04/01  15:34:43  ram
  113. X# patch1: added des target
  114. X# 
  115. X# Revision 2.0  91/02/19  15:48:41  ram
  116. X# Baseline for first official release.
  117. X# 
  118. X
  119. SHELL = /bin/sh
  120. X
  121. SUBDIRS = btoa kit man des
  122. RM = $rm
  123. X!GROK!THIS!
  124. X$spitshell >>Makefile <<'!NO!SUBS!'
  125. X
  126. X#
  127. X#    Building rules
  128. X#
  129. X
  130. all install clean realclean: makefiles
  131. X    -@for dir in $(SUBDIRS); do \
  132. X        (cd $$dir && make $@) \
  133. X    done
  134. X
  135. makefiles:
  136. X    -@for dir in $(SUBDIRS); do \
  137. X        (cd $$dir && if test ! -f Makefile; then \
  138. X            sh Makefile.SH; fi) \
  139. X    done
  140. X
  141. clobber: makefiles
  142. X    -@for dir in $(SUBDIRS); do \
  143. X        (cd $$dir && make $@) \
  144. X    done
  145. X    $(RM) -f config.h config.sh Makefile install cppstdin
  146. X!NO!SUBS!
  147. chmod 755 Makefile
  148. X$eunicefix Makefile
  149. END_OF_FILE
  150. if test 1456 -ne `wc -c <'Makefile.SH'`; then
  151.     echo shar: \"'Makefile.SH'\" unpacked with wrong size!
  152. fi
  153. chmod +x 'Makefile.SH'
  154. # end of 'Makefile.SH'
  155. fi
  156. if test -f 'README' -a "${1}" != "-c" ; then 
  157.   echo shar: Will not clobber existing file \"'README'\"
  158. else
  159. echo shar: Extracting \"'README'\" \(2822 characters\)
  160. sed "s/^X//" >'README' <<'END_OF_FILE'
  161. X                             kit 2.0
  162. X
  163. X             Copyright (c) 1990 1991, Raphael Manfredi
  164. X
  165. You may copy this kit in whole or in part as long as you don't try to
  166. make money off it, or pretend you wrote it.
  167. X------------------------------------------------------------------------
  168. The ultimate mailing kit -- Assumes you own cshar (written by Rich Salz)
  169. X
  170. Please read all the directions below before you proceed any further, and
  171. then follow them carefully.
  172. X
  173. After you have unpacked your kit, you should have all the files listed
  174. in MANIFEST.
  175. X
  176. If you only wish to use unkit, then CSHAR is not necessary, though
  177. strongly recommended.
  178. X
  179. In order to use kit, you need to install CSHAR in your PATH (programs
  180. needed are shar, makekit and unshar). Compress must be available. If you
  181. miss one of those, send me a mail: ram@eiffel.com (Raphael Manfredi).
  182. X
  183. Moreover, hexdecode, hexencode, atob and btoa must be installed. The
  184. public-domain implementation of des, which is provided with kit, must
  185. also be in your PATH if you want to use the encryption facilities.
  186. X
  187. X
  188. INSTALLATION
  189. X
  190. X1) Run Configure. This will figure out various things about your
  191. system. After it has been completed, it will produce config.h and
  192. config.sh.
  193. X
  194. You might have to trim # comments from the front of Configure if your
  195. shell doesn't handle them, but any other comments will be taken care of.
  196. X
  197. X2) Run make.
  198. X
  199. X3) If make succeeded, you may wish to do make install. Be sure your
  200. rights are correct (if you install manual pages, you may need
  201. super-user privileges).
  202. X
  203. X4) Read the manual entries before running.
  204. X
  205. X5) IMPORTANT! Communicate any problem and suggested patches to
  206. me, ram@eiffel.com (Raphael Manfredi), so we can keep this
  207. distribution in sync. If you have a problem, there will be someone
  208. who might have had it or will have it too.
  209. X
  210. If possible, send me patches such that the patch program will
  211. apply them. Context diffs are the best, then normal diffs. Do not
  212. send ed scripts: I have probably changed my copy since the version
  213. you got.
  214. X
  215. X6) After everything is installed, you can do "make clobber". This will
  216. clean up everything and let you re-distribute this kit, without
  217. carrying useless files. You should keep this distribution intact, so
  218. that future patches will be applicable.
  219. X
  220. X7) I have an automatic patch sender. Send me a mail of the following
  221. form:
  222. X
  223. X    Subject: Command
  224. X    @SH mailhelp PATH
  225. X
  226. and you will get instructions about how to use it. PATH stands for
  227. YOUR e-mail address, either in INTERNET form or in bang notation.
  228. X
  229. X
  230. CREDITS
  231. X
  232. Kit relies on two public-domain softwares:
  233. X
  234. X    - cshar, written by Rich Salz.
  235. X    - des, written by Phil Karn, which is provided with kit.
  236. X
  237. To maintain and configure kit, I use the dist 2.0 package written
  238. by Larry Wall with some significant changes. If you wish to get a
  239. copy of it, feel free to ask me.
  240. X
  241. X    -- Raphael
  242. END_OF_FILE
  243. if test 2822 -ne `wc -c <'README'`; then
  244.     echo shar: \"'README'\" unpacked with wrong size!
  245. fi
  246. # end of 'README'
  247. fi
  248. if test ! -d 'btoa' ; then
  249.     echo shar: Creating directory \"'btoa'\"
  250.     mkdir 'btoa'
  251. fi
  252. if test -f 'btoa/Makefile.SH' -a "${1}" != "-c" ; then 
  253.   echo shar: Will not clobber existing file \"'btoa/Makefile.SH'\"
  254. else
  255. echo shar: Extracting \"'btoa/Makefile.SH'\" \(1270 characters\)
  256. sed "s/^X//" >'btoa/Makefile.SH' <<'END_OF_FILE'
  257. case $CONFIG in
  258. X'')
  259. X    if test ! -f config.sh; then
  260. X    ln ../config.sh . || \
  261. X    ln ../../config.sh . || \
  262. X    ln ../../../config.sh . || \
  263. X    (echo "Can't find config.sh."; exit 1)
  264. X    fi 2>/dev/null
  265. X    . config.sh
  266. X    ;;
  267. esac
  268. case "$0" in
  269. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  270. esac
  271. echo "Extracting btoa/Makefile (with variable substitutions)"
  272. X$spitshell >Makefile <<!GROK!THIS!
  273. X#
  274. X# Makefile for kit (sub-directory btoa)
  275. X#
  276. X
  277. X# $Id: Makefile.SH,v 2.0.1.1 91/05/27 14:14:41 ram Exp $
  278. X#
  279. X# $Log:    Makefile.SH,v $
  280. X# Revision 2.0.1.1  91/05/27  14:14:41  ram
  281. X# patch5: some dumb make failed on previous makefile
  282. X# 
  283. X# Revision 2.0  91/02/19  15:49:16  ram
  284. X# Baseline for first official release.
  285. X# 
  286. X
  287. SHELL = /bin/sh
  288. X
  289. CC = $cc
  290. CFLAGS = $ccflags $optimize
  291. RM = $rm
  292. bin = $bin
  293. X
  294. X!GROK!THIS!
  295. X$spitshell >>Makefile <<'!NO!SUBS!'
  296. BIN = btoa atob hexencode hexdecode
  297. X
  298. all: $(BIN)
  299. X
  300. btoa: btoa.c
  301. X    $(CC) $(CFLAGS) -o $@ $@.c
  302. X
  303. atob: atob.c
  304. X    $(CC) $(CFLAGS) -o $@ $@.c
  305. X
  306. hexencode: hexencode.c
  307. X    $(CC) $(CFLAGS) -o $@ $@.c
  308. X
  309. hexdecode: hexdecode.c
  310. X    $(CC) $(CFLAGS) -o $@ $@.c
  311. X
  312. install: $(BIN)
  313. X    -for file in $(BIN); do \
  314. X        ../install -s -m 755 $$file $(bin); \
  315. X    done
  316. X
  317. clean:
  318. X    $(RM) -f *.o $(BIN)
  319. X
  320. realclean clobber: clean
  321. X    $(RM) -f core Makefile config.sh
  322. X!NO!SUBS!
  323. chmod 644 Makefile
  324. X$eunicefix Makefile
  325. END_OF_FILE
  326. if test 1270 -ne `wc -c <'btoa/Makefile.SH'`; then
  327.     echo shar: \"'btoa/Makefile.SH'\" unpacked with wrong size!
  328. fi
  329. chmod +x 'btoa/Makefile.SH'
  330. # end of 'btoa/Makefile.SH'
  331. fi
  332. if test -f 'btoa/atob.c' -a "${1}" != "-c" ; then 
  333.   echo shar: Will not clobber existing file \"'btoa/atob.c'\"
  334. else
  335. echo shar: Extracting \"'btoa/atob.c'\" \(3277 characters\)
  336. sed "s/^X//" >'btoa/atob.c' <<'END_OF_FILE'
  337. X/*
  338. X
  339. X   ##     #####   ####   #####            ####
  340. X  #  #      #    #    #  #    #          #    #
  341. X #    #     #    #    #  #####           #
  342. X ######     #    #    #  #    #   ###    #
  343. X #    #     #    #    #  #    #   ###    #    #
  344. X #    #     #     ####   #####    ###     ####
  345. X
  346. X    stream filter to change printable ascii from "btoa" back into
  347. X    8 bit bytes if bad chars, or Csums do not match: exit(1)
  348. X    [and NO output]
  349. X
  350. X    Paul Rutter Joe Orost
  351. X
  352. X    Raphael Manfredi (ram) modified this file, in order to produce
  353. X    meaningfull error messages (otherwise, fatal() was called, even
  354. X    when a temporary file could not be created...); added error()
  355. X*/
  356. X
  357. X/*
  358. X * $Id: atob.c,v 2.0 91/02/19 15:49:21 ram Exp $
  359. X *
  360. X * $Log:    atob.c,v $
  361. X * Revision 2.0  91/02/19  15:49:21  ram
  362. X * Baseline for first official release.
  363. X * 
  364. X */
  365. X
  366. X#include <stdio.h>
  367. X
  368. X#define reg register
  369. X
  370. X#define streq(s0, s1)  strcmp(s0, s1) == 0
  371. X
  372. X#define times85(x)    ((((((x<<2)+x)<<2)+x)<<2)+x)
  373. X
  374. long int Ceor = 0;
  375. long int Csum = 0;
  376. long int Crot = 0;
  377. long int word = 0;
  378. long int bcount = 0;
  379. X
  380. fatal() {
  381. X  fprintf(stderr, "bad format or Csum to atob\n");
  382. X  exit(1);
  383. X}
  384. X
  385. error(s)
  386. char *s;    /* the error message */
  387. X{
  388. X  fprintf(stderr, "%s\n", s);
  389. X  exit(1);
  390. X}
  391. X
  392. X#define DE(c) ((c) - '!')
  393. X
  394. decode(c) reg c;
  395. X{
  396. X  if (c == 'z') {
  397. X    if (bcount != 0) {
  398. X      fatal();
  399. X    } 
  400. X    else {
  401. X      byteout(0);
  402. X      byteout(0);
  403. X      byteout(0);
  404. X      byteout(0);
  405. X    }
  406. X  } 
  407. X  else if ((c >= '!') && (c < ('!' + 85))) {
  408. X    if (bcount == 0) {
  409. X      word = DE(c);
  410. X      ++bcount;
  411. X    } 
  412. X    else if (bcount < 4) {
  413. X      word = times85(word);
  414. X      word += DE(c);
  415. X      ++bcount;
  416. X    } 
  417. X    else {
  418. X      word = times85(word) + DE(c);
  419. X      byteout((int)((word >> 24) & 255));
  420. X      byteout((int)((word >> 16) & 255));
  421. X      byteout((int)((word >> 8) & 255));
  422. X      byteout((int)(word & 255));
  423. X      word = 0;
  424. X      bcount = 0;
  425. X    }
  426. X  } 
  427. X  else {
  428. X    fatal();
  429. X  }
  430. X}
  431. X
  432. XFILE *tmp_file;
  433. X
  434. byteout(c) reg c;
  435. X{
  436. X  Ceor ^= c;
  437. X  Csum += c;
  438. X  Csum += 1;
  439. X  if ((Crot & 0x80000000)) {
  440. X    Crot <<= 1;
  441. X    Crot += 1;
  442. X  } 
  443. X  else {
  444. X    Crot <<= 1;
  445. X  }
  446. X  Crot += c;
  447. X  putc(c, tmp_file);
  448. X}
  449. X
  450. main(argc, argv) char **argv;
  451. X{
  452. X  reg c;
  453. X  reg long int i;
  454. X  char tmp_name[100];
  455. X  char buf[100];
  456. X  long int n1, n2, oeor, osum, orot;
  457. X
  458. X  if (argc != 1) {
  459. X    fprintf(stderr,"bad args to %s\n", argv[0]);
  460. X    exit(2);
  461. X  }
  462. X  sprintf(tmp_name, "/usr/tmp/atob.%x", getpid());
  463. X  tmp_file = fopen(tmp_name, "w+");
  464. X  if (tmp_file == NULL) {
  465. X    error("can't create temporary file");
  466. X  }
  467. X  unlink(tmp_name); /* Make file disappear */
  468. X  /*search for header line*/
  469. X  for (;;) {
  470. X    if (fgets(buf, sizeof buf, stdin) == NULL) {
  471. X      error("could not read header line");
  472. X    }
  473. X    if (streq(buf, "xbtoa Begin\n")) {
  474. X      break;
  475. X    }
  476. X  }
  477. X
  478. X  while ((c = getchar()) != EOF) {
  479. X    if (c == '\n') {
  480. X      continue;
  481. X    } 
  482. X    else if (c == 'x') {
  483. X      break;
  484. X    } 
  485. X    else {
  486. X      decode(c);
  487. X    }
  488. X  }
  489. X  if (scanf("btoa End N %ld %lx E %lx S %lx R %lx\n", &n1, &n2, &oeor, &osum, &orot) != 5) {
  490. X    error("could not read check sum");
  491. X  }
  492. X  if ((n1 != n2) || (oeor != Ceor) || (osum != Csum) || (orot != Crot)) {
  493. X    fatal();
  494. X  } 
  495. X  else {
  496. X    /*copy OK tmp file to stdout*/;
  497. X    fseek(tmp_file, 0L, 0);
  498. X    for (i = n1; --i >= 0;) {
  499. X      putchar(getc(tmp_file));
  500. X    }
  501. X  }
  502. X  exit(0);
  503. X}
  504. END_OF_FILE
  505. if test 3277 -ne `wc -c <'btoa/atob.c'`; then
  506.     echo shar: \"'btoa/atob.c'\" unpacked with wrong size!
  507. fi
  508. # end of 'btoa/atob.c'
  509. fi
  510. if test -f 'btoa/btoa.c' -a "${1}" != "-c" ; then 
  511.   echo shar: Will not clobber existing file \"'btoa/btoa.c'\"
  512. else
  513. echo shar: Extracting \"'btoa/btoa.c'\" \(2696 characters\)
  514. sed "s/^X//" >'btoa/btoa.c' <<'END_OF_FILE'
  515. X/*
  516. X
  517. X #####    #####   ####     ##             ####
  518. X #    #     #    #    #   #  #           #    #
  519. X #####      #    #    #  #    #          #
  520. X #    #     #    #    #  ######   ###    #
  521. X #    #     #    #    #  #    #   ###    #    #
  522. X #####      #     ####   #    #   ###     ####
  523. X
  524. X    btoa: version 4.0
  525. X    stream filter to change 8 bit bytes into printable ascii
  526. X    computes the number of bytes, and three kinds of simple checksums
  527. X    incoming bytes are collected into 32-bit words, then printed in
  528. X    base 85 exp(85,5) > exp(2,32)
  529. X    the ASCII characters used are between '!' and 'u'
  530. X    'z' encodes 32-bit zero; 'x' is used to mark the end of encoded data.
  531. X
  532. X    Paul Rutter Joe Orost
  533. X*/
  534. X
  535. X/*
  536. X * $Id: btoa.c,v 2.0 91/02/19 15:49:25 ram Exp $
  537. X *
  538. X * $Log:    btoa.c,v $
  539. X * Revision 2.0  91/02/19  15:49:25  ram
  540. X * Baseline for first official release.
  541. X * 
  542. X */
  543. X
  544. X#include <stdio.h>
  545. X
  546. X#define reg register
  547. X
  548. X#define MAXPERLINE 78
  549. X
  550. long int Ceor = 0;
  551. long int Csum = 0;
  552. long int Crot = 0;
  553. X
  554. long int ccount = 0;
  555. long int bcount = 0;
  556. long int word;
  557. X
  558. X#define EN(c)    (int) ((c) + '!')
  559. X
  560. encode(c) reg c;
  561. X{
  562. X  Ceor ^= c;
  563. X  Csum += c;
  564. X  Csum += 1;
  565. X  if ((Crot & 0x80000000)) {
  566. X    Crot <<= 1;
  567. X    Crot += 1;
  568. X  } 
  569. X  else {
  570. X    Crot <<= 1;
  571. X  }
  572. X  Crot += c;
  573. X
  574. X  word <<= 8;
  575. X  word |= c;
  576. X  if (bcount == 3) {
  577. X    wordout(word);
  578. X    bcount = 0;
  579. X  } 
  580. X  else {
  581. X    bcount += 1;
  582. X  }
  583. X}
  584. X
  585. wordout(word) reg long int word;
  586. X{
  587. X  if (word == 0) {
  588. X    charout('z');
  589. X  } 
  590. X  else {
  591. X    reg int tmp = 0;
  592. X
  593. X    if (word < 0)
  594. X    { /* Because some don't support unsigned long */
  595. X      tmp = 32;
  596. X      word = word - (long)(85 * 85 * 85 * 85 * 32);
  597. X    }
  598. X    if (word < 0) {
  599. X      tmp = 64;
  600. X      word = word - (long)(85 * 85 * 85 * 85 * 32);
  601. X    }
  602. X    charout(EN((word / (long)(85 * 85 * 85 * 85)) + tmp));
  603. X    word %= (long)(85 * 85 * 85 * 85);
  604. X    charout(EN(word / (85 * 85 * 85)));
  605. X    word %= (85 * 85 * 85);
  606. X    charout(EN(word / (85 * 85)));
  607. X    word %= (85 * 85);
  608. X    charout(EN(word / 85));
  609. X    word %= 85;
  610. X    charout(EN(word));
  611. X  }
  612. X}
  613. X
  614. charout(c) {
  615. X  putchar(c);
  616. X  ccount += 1;
  617. X  if (ccount == MAXPERLINE) {
  618. X    putchar('\n');
  619. X    ccount = 0;
  620. X  }
  621. X}
  622. X
  623. main(argc,argv)
  624. char **argv;
  625. X{
  626. X  reg c;
  627. X  reg long int n;
  628. X
  629. X  if (argc != 1) {
  630. X    fprintf(stderr,"bad args to %s\n", argv[0]);
  631. X    exit(2);
  632. X  }
  633. X  printf("xbtoa Begin\n");
  634. X  n = 0;
  635. X  while ((c = getchar()) != EOF) {
  636. X    encode(c);
  637. X    n += 1;
  638. X  }
  639. X  while (bcount != 0) {
  640. X    encode(0);
  641. X  }
  642. X  /* n is written twice as crude cross check*/
  643. X  if (ccount == 0) /* ccount == 0 means '\n' just written in charout() */
  644. X    ; /* this avoids bug in BITNET, which changes blank line to spaces */
  645. X  else
  646. X    putchar('\n');
  647. X  printf("xbtoa End N %ld %lx E %lx S %lx R %lx\n", n, n, Ceor, Csum, Crot);
  648. X  exit(0);
  649. X}
  650. END_OF_FILE
  651. if test 2696 -ne `wc -c <'btoa/btoa.c'`; then
  652.     echo shar: \"'btoa/btoa.c'\" unpacked with wrong size!
  653. fi
  654. # end of 'btoa/btoa.c'
  655. fi
  656. if test -f 'btoa/hexdecode.c' -a "${1}" != "-c" ; then 
  657.   echo shar: Will not clobber existing file \"'btoa/hexdecode.c'\"
  658. else
  659. echo shar: Extracting \"'btoa/hexdecode.c'\" \(1276 characters\)
  660. sed "s/^X//" >'btoa/hexdecode.c' <<'END_OF_FILE'
  661. X
  662. X/*
  663. X
  664. X #    #  ######  #    #  #####   ######   ####    ####   #####   ######
  665. X #    #  #        #  #   #    #  #       #    #  #    #  #    #  #
  666. X ######  #####     ##    #    #  #####   #       #    #  #    #  #####
  667. X #    #  #         ##    #    #  #       #       #    #  #    #  #        ###
  668. X #    #  #        #  #   #    #  #       #    #  #    #  #    #  #        ###
  669. X #    #  ######  #    #  #####   ######   ####    ####   #####   ######   ###
  670. X
  671. X    Converts hex from stdin to stdout.
  672. X
  673. X    R. Manfredi and E. Mogenet, June 1990.
  674. X*/
  675. X
  676. X/*
  677. X * $Id: hexdecode.c,v 2.0 91/02/19 15:49:29 ram Exp $
  678. X *
  679. X * $Log:    hexdecode.c,v $
  680. X * Revision 2.0  91/02/19  15:49:29  ram
  681. X * Baseline for first official release.
  682. X * 
  683. X */
  684. X
  685. X#include <stdio.h>
  686. X
  687. static char    rcs_id[] = "@(#)hexdecode, convert hex from stdin to stdout";
  688. X
  689. X#define ishexa(x) (((x)>='0' && (x)<='9') || ((x)>='A' && (x)<='F'))
  690. X#define tohexa(x) ( (x)>='A' ? (x)-'A'+0xA : (x)-'0' )
  691. X
  692. main(argc, argv)
  693. int    argc;
  694. char    **argv;
  695. X{
  696. X    int    c1, c2;
  697. X
  698. X    while (EOF != (c1 = getchar())) {
  699. X        if (ishexa(c1)) {
  700. X            c2 = getchar();
  701. X            if (ishexa(c2))
  702. X                putchar((tohexa(c1) << 4) | (tohexa(c2)));
  703. X            else
  704. X                goto corrupted;
  705. X        } else if ( c1 != '\n' ) {
  706. corrupted:
  707. X            fprintf(stderr, "%s: file corrupted\n", argv[0]);
  708. X            exit(1);
  709. X        }
  710. X    }
  711. X    exit(0);
  712. X}
  713. X
  714. X
  715. END_OF_FILE
  716. if test 1276 -ne `wc -c <'btoa/hexdecode.c'`; then
  717.     echo shar: \"'btoa/hexdecode.c'\" unpacked with wrong size!
  718. fi
  719. # end of 'btoa/hexdecode.c'
  720. fi
  721. if test -f 'btoa/hexencode.c' -a "${1}" != "-c" ; then 
  722.   echo shar: Will not clobber existing file \"'btoa/hexencode.c'\"
  723. else
  724. echo shar: Extracting \"'btoa/hexencode.c'\" \(1066 characters\)
  725. sed "s/^X//" >'btoa/hexencode.c' <<'END_OF_FILE'
  726. X/*
  727. X
  728. X #    #  ######  #    #  ######  #    #   ####    ####   #####   ######
  729. X #    #  #        #  #   #       ##   #  #    #  #    #  #    #  #
  730. X ######  #####     ##    #####   # #  #  #       #    #  #    #  #####
  731. X #    #  #         ##    #       #  # #  #       #    #  #    #  #        ###
  732. X #    #  #        #  #   #       #   ##  #    #  #    #  #    #  #        ###
  733. X #    #  ######  #    #  ######  #    #   ####    ####   #####   ######   ###
  734. X
  735. X    stdout = hexa(stdin)
  736. X
  737. X    R. Manfredi and E. Mogenet
  738. X*/
  739. X
  740. X/*
  741. X * $Id: hexencode.c,v 2.0 91/02/19 15:49:33 ram Exp $
  742. X *
  743. X * $Log:    hexencode.c,v $
  744. X * Revision 2.0  91/02/19  15:49:33  ram
  745. X * Baseline for first official release.
  746. X * 
  747. X */
  748. X
  749. X#include <stdio.h>
  750. X
  751. static char    rcs_id[] = "@(#)hexencode, stdout = hexa(stdin)";
  752. X
  753. X#define QUARTET 0xF
  754. static char    hexa[] = "0123456789ABCDEF";
  755. X
  756. main()
  757. X{
  758. X    int    c;
  759. X    int    jump;
  760. X
  761. X
  762. X    jump = 0;
  763. X    while (EOF != (c = getchar())) {
  764. X        putchar(hexa[(c>>4) & QUARTET]);
  765. X        putchar(hexa[c & QUARTET]);
  766. X        jump += 2;
  767. X        if ( jump > 75 ) {
  768. X            putchar('\n');
  769. X            jump = 0;
  770. X        }
  771. X    }
  772. X    putchar('\n');
  773. X    exit(0);
  774. X}
  775. X
  776. X
  777. END_OF_FILE
  778. if test 1066 -ne `wc -c <'btoa/hexencode.c'`; then
  779.     echo shar: \"'btoa/hexencode.c'\" unpacked with wrong size!
  780. fi
  781. # end of 'btoa/hexencode.c'
  782. fi
  783. if test ! -d 'des' ; then
  784.     echo shar: Creating directory \"'des'\"
  785.     mkdir 'des'
  786. fi
  787. if test -f 'des/Makefile.SH' -a "${1}" != "-c" ; then 
  788.   echo shar: Will not clobber existing file \"'des/Makefile.SH'\"
  789. else
  790. echo shar: Extracting \"'des/Makefile.SH'\" \(1473 characters\)
  791. sed "s/^X//" >'des/Makefile.SH' <<'END_OF_FILE'
  792. case $CONFIG in
  793. X'')
  794. X    if test ! -f config.sh; then
  795. X        ln ../config.sh . || \
  796. X        ln ../../config.sh . || \
  797. X        ln ../../../config.sh . || \
  798. X        (echo "Can't find config.sh."; exit 1)
  799. X    fi 2>/dev/null
  800. X    . config.sh
  801. X    ;;
  802. esac
  803. case "$0" in
  804. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  805. esac
  806. echo "Extracting des/Makefile (with variable substitutions)"
  807. X$spitshell >Makefile <<!GROK!THIS!
  808. X#
  809. X# Makefile for kit (sub-directory des)
  810. X#
  811. X
  812. X# $Id: Makefile.SH,v 2.0.1.3 91/11/25 12:03:16 ram Exp $
  813. X#
  814. X# $Log:    Makefile.SH,v $
  815. X# Revision 2.0.1.3  91/11/25  12:03:16  ram
  816. X# patch8: this file was stamped with a wrong package name
  817. X# 
  818. X# Revision 2.0.1.2  91/05/27  14:15:38  ram
  819. X# patch5: some dumb make failed on previous makefile
  820. X# 
  821. X# Revision 2.0.1.1  91/04/01  15:38:51  ram
  822. X# patch1: created
  823. X# 
  824. X
  825. SHELL = /bin/sh
  826. X
  827. ALL = certify des
  828. CC = $cc
  829. CFLAGS = $ccflags $optimize
  830. MAKE = make
  831. RM = $rm
  832. bin = $bin
  833. X!GROK!THIS!
  834. X$spitshell >>Makefile <<'!NO!SUBS!'
  835. X
  836. all: $(ALL)
  837. X
  838. des: main.o des.o getpass.o misc.o getopt.o
  839. X    $(CC) $(CFLAGS) -o des main.o des.o getpass.o misc.o getopt.o
  840. X
  841. descert: descert.o des.o
  842. X    $(CC) $(CFLAGS) -o descert descert.o des.o
  843. X
  844. certify: testdata
  845. X    $(MAKE) $(MFLAGS) descert
  846. X    if ./descert < testdata; then touch certify; $(RM) descert descert.o; fi
  847. X
  848. install: des
  849. X    ../install -s -m 755 des $(bin)
  850. X    @echo "    Warning: manual pages for des not installed."
  851. X
  852. clean:
  853. X    rm -f *.o des descert
  854. X
  855. realclean clobber: clean
  856. X    $(RM) -f certify core Makefile config.sh
  857. X!NO!SUBS!
  858. chmod 755 Makefile
  859. X$eunicefix Makefile
  860. END_OF_FILE
  861. if test 1473 -ne `wc -c <'des/Makefile.SH'`; then
  862.     echo shar: \"'des/Makefile.SH'\" unpacked with wrong size!
  863. fi
  864. # end of 'des/Makefile.SH'
  865. fi
  866. if test -f 'des/README' -a "${1}" != "-c" ; then 
  867.   echo shar: Will not clobber existing file \"'des/README'\"
  868. else
  869. echo shar: Extracting \"'des/README'\" \(1687 characters\)
  870. sed "s/^X//" >'des/README' <<'END_OF_FILE'
  871. Here is an excerpt from the original public-domain DES package, written
  872. by Phil Karn and cleaned up by Bdale Garbee. I removed all the unneeded
  873. stuff for kit, and I added some defines in the code, so that it can
  874. be meta-configured. I also rewrote the Makefile.
  875. X
  876. I left the two man pages des.1 and des.3, but the main Makefile won't
  877. install them, because they may conflict with already existing manual
  878. pages. However, des itself is installed, because kit needs it for
  879. its encryption facilities.
  880. X
  881. Raphael Manfredi <ram@eiffel.com>
  882. X
  883. X- - - - -
  884. X
  885. Phil asked me to clean this up slightly and package it for distribution.
  886. I've got it running on my Symmetric 4.2bsd system, Phil reports it runs fine
  887. on a variety of systems at Bellcore.  Note that getopt is required but not
  888. provided, as there is already a getopt package in the mod.sources archives.
  889. X
  890. Bdale Garbee, N3EUA  870401    
  891. winfree!bdale aka bdale%winfree.uucp@flash.bellcore.com
  892. X
  893. X- - - - -
  894. X
  895. This package contains a DES subroutine library based on the original public
  896. domain code by James Gillogly, but made faster and more flexible. Commands
  897. using this library have been added for testing and for encrypting and
  898. decrypting files (compatible with the DES command under Sun UNIX), among
  899. other things.
  900. X
  901. Run make. That will compile everything and run test data (from the NBS
  902. certification suite) through it.  It runs as-is under UNIX. It will run
  903. under MS-DOS with a few minor changes: make sure you define LITTLE_ENDIAN
  904. when compiling des.c, and change the name of the console in getpass.c.  If
  905. you have the byte order flag set wrong, you will get ENCRYPT FAIL messages
  906. when the descert test is run.
  907. X
  908. Phil Karn, KA9Q
  909. karn@flash.bellcore.com
  910. END_OF_FILE
  911. if test 1687 -ne `wc -c <'des/README'`; then
  912.     echo shar: \"'des/README'\" unpacked with wrong size!
  913. fi
  914. # end of 'des/README'
  915. fi
  916. if test -f 'des/des.1' -a "${1}" != "-c" ; then 
  917.   echo shar: Will not clobber existing file \"'des/des.1'\"
  918. else
  919. echo shar: Extracting \"'des/des.1'\" \(3926 characters\)
  920. sed "s/^X//" >'des/des.1' <<'END_OF_FILE'
  921. X.TH DES 1  "30 March 1991"
  922. X'''
  923. X''' $Id: des.1,v 2.0.1.1 91/04/01 15:39:16 ram Exp $
  924. X'''
  925. X''' $Log:    des.1,v $
  926. X''' Revision 2.0.1.1  91/04/01  15:39:16  ram
  927. X''' patch1: created
  928. X''' 
  929. X'''
  930. X.SH NAME
  931. des - DES file encryption
  932. X.SH SYNOPSIS
  933. X.PP
  934. X.B des -e|-d [-h] [-k key] [-b]
  935. X.SH DESCRIPTION
  936. X.B Des
  937. is a filter that encrypts or decrypts standard input to standard output
  938. with the Data Encryption Standard (DES).
  939. XEither -e (encrypt) or -d (decrypt) must be specified. If the key is not
  940. given on the command line with the -k option the command will prompt for it
  941. twice, suppressing echo and comparing the two responses to guard against
  942. mistyping.
  943. X.PP
  944. The
  945. X.B des
  946. command is provided to promote secure exchange of data in a standard
  947. fashion.
  948. X.PP
  949. The -h flag controls how the key string is to be interpreted. Without
  950. the -h flag, the key is an ASCII string. Since DES ignores the low
  951. order bit of each key byte, the high order bit is set for odd parity,
  952. thus retaining the information contained in the low order bit. If the
  953. X-h flag is set, the key string is interpreted as 16 hex/ASCII
  954. characters; the low order bit of each byte is again ignored as per the
  955. DES algorithm. This allows the use of any arbitrary 56-bit key,
  956. including bytes representing control characters that could not be typed
  957. if the -h option were not used.
  958. X.PP
  959. By default, DES Cipher Block Chaining (CBC) mode is used, with an initial
  960. vector (IV) of all zeros; if the -b option is specified, Electronic Code
  961. Book (ECB, eight bytes at a time) mode is used instead.
  962. X.PP
  963. The CBC mode treats an entire file as a unit of encryption, that is,
  964. if insertions or deletions are made to the encrypted file then
  965. decryption will not succeed.
  966. CBC mode also ensures  that regularities in clear data do not appear
  967. in the encrypted data.
  968. X.PP
  969. XECB mode treats each 8 bytes as units of encryptions, so if parts
  970. of the encrypted file are modified then other parts may still be
  971. decrypted. Identical values of clear text encrypt to identical values of
  972. cipher text.
  973. X.PP
  974. If the key is an argument to the
  975. X.B des
  976. command, it is potentially visible to users executing
  977. X.BR ps (1)
  978. or a derivative.
  979. To minimize this possibility,
  980. X.B des
  981. takes care to destroy the key argument immediately upon entry.
  982. X.PP
  983. The following sections give information required to implement compatible
  984. facilities in other environments.
  985. X.LP
  986. Since the CBC and ECB modes of DES require units of 8 bytes to be
  987. encrypted, files being encrypted by the
  988. X.B des
  989. command have 1 to 8 bytes appended to them to cause them to be a
  990. multiple of 8 bytes. The last byte, when decrypted, gives the number
  991. of bytes (0 to 7) which are to be saved of the last 8 bytes. The other
  992. bytes of those appended to the input are randomized before encryption.
  993. If, when decrypting, the last byte is not in the range of 0 to 7 then
  994. either the encrypted file has been corrupted or an incorrect key was
  995. provided for decryption and an error message is printed.
  996. X.LP
  997. The DES
  998. algorithm requires an 8 byte key whose low order bits are assumed to be
  999. odd-parity bits. The ASCII key supplied by the user is zero padded to
  1000. X8 bytes and the high order bits are set to be odd-parity bits. The
  1001. DES algorithm then ignores the low bit of each ASCII
  1002. character, but that bit's information has been preserved in the high
  1003. bit due to the parity.
  1004. X.LP
  1005. The CBC mode of operation always uses an initial value of all zeros for
  1006. the initialization vector, so the first 8 bytes of a file are
  1007. encrypted the same whether in CBC or ECB mode.
  1008. X.PP
  1009. XExcept for the -h option, this command is compatible with the
  1010. X.B des
  1011. command on the Sun Microsystems workstation.
  1012. X.SH BUGS
  1013. X.LP
  1014. It would be better to use a real 56-bit key rather than an
  1015. ASCII-based 56-bit pattern.  Knowing that the key was derived from
  1016. ASCII radically reduces the time necessary for a brute-force
  1017. crytographic attack.
  1018. X.SH AUTHOR
  1019. Phil Karn, KA9Q.
  1020. X.br
  1021. Manual page updated by Raphael Manfredi, from the SUN-OS
  1022. X.BR des (1)
  1023. manual page.
  1024. END_OF_FILE
  1025. if test 3926 -ne `wc -c <'des/des.1'`; then
  1026.     echo shar: \"'des/des.1'\" unpacked with wrong size!
  1027. fi
  1028. # end of 'des/des.1'
  1029. fi
  1030. if test -f 'des/des.3' -a "${1}" != "-c" ; then 
  1031.   echo shar: Will not clobber existing file \"'des/des.3'\"
  1032. else
  1033. echo shar: Extracting \"'des/des.3'\" \(2112 characters\)
  1034. sed "s/^X//" >'des/des.3' <<'END_OF_FILE'
  1035. X.TH DES 3  "24 March 1987"
  1036. X'''
  1037. X''' $Id: des.3,v 2.0.1.1 91/04/01 15:39:26 ram Exp $
  1038. X'''
  1039. X''' $Log:    des.3,v $
  1040. X''' Revision 2.0.1.1  91/04/01  15:39:26  ram
  1041. X''' patch1: created
  1042. X''' 
  1043. X'''
  1044. X.SH NAME
  1045. desinit, setkey, endes, dedes, desdone - DES encryption
  1046. X.SH SYNOPSIS
  1047. X.PP
  1048. X.B desinit(mode)
  1049. X.B int mode;
  1050. X.PP
  1051. X.B setkey(key)
  1052. X.B char *key;
  1053. X.PP
  1054. X.B endes(block)
  1055. X.B char *block;
  1056. X.PP
  1057. X.B dedes(block)
  1058. X.B char *block;
  1059. X.PP
  1060. X.B desdone()
  1061. X.SH DESCRIPTION
  1062. These routines implement both standard and modified forms of the NBS Data
  1063. XEncryption Standard (DES). The user must first call
  1064. X.B desinit
  1065. with one of three operating modes:
  1066. X.PP
  1067. X0 - Standard, vanilla DES.
  1068. X.PP
  1069. X1 - DES with the initial and final permutations removed.
  1070. As these permutations do not strengthen the algorithm,
  1071. they are widely regarded as having no purpose other than to slow
  1072. down software implementations.
  1073. Removing them speeds it up but of course the algorithm is no longer standard
  1074. and it will not be compatible with hardware DES chips.
  1075. X.PP
  1076. X2 - DES with the initial and final permutations removed, and with independent
  1077. X48-bit subkeys for each of the 16 rounds. Needless to say this is even
  1078. less standard than mode 1, but if properly used (randomize ALL key bytes --
  1079. no padding!) it should strengthen the algorithm.
  1080. X.PP
  1081. After calling
  1082. X.B desinit
  1083. the user next calls
  1084. X.B setkey.
  1085. In modes 0 and 1, 8 key bytes are expected, with the low order bit of
  1086. each key byte ignored (parity is not checked). This gives a 56-bit key.
  1087. In mode 2, 128 key bytes are expected; the high order 2 bits of each byte are
  1088. ignored, giving a 768 bit key.
  1089. In this mode, the first 8 bytes will be used in the first round, the
  1090. second 8 bytes in the second round, and so on.
  1091. X.PP
  1092. Once the key is set, the user may perform in-place encryption and decryption
  1093. of 8-byte blocks of data with calls to
  1094. X.B endes
  1095. and
  1096. X.B dedes.
  1097. X.PP
  1098. To free up memory dynamically allocated by
  1099. X.B desinit
  1100. the user may call
  1101. X.B desdone.
  1102. If further encryption or decryption is to be done,
  1103. X.B desinit
  1104. and
  1105. X.B setkey
  1106. must be called again.
  1107. X.SH AUTHOR
  1108. Phil Karn, KA9Q, building heavily on the earlier public domain code
  1109. by Jim Gillogly.
  1110. X
  1111. X
  1112. END_OF_FILE
  1113. if test 2112 -ne `wc -c <'des/des.3'`; then
  1114.     echo shar: \"'des/des.3'\" unpacked with wrong size!
  1115. fi
  1116. # end of 'des/des.3'
  1117. fi
  1118. if test -f 'des/descert.c' -a "${1}" != "-c" ; then 
  1119.   echo shar: Will not clobber existing file \"'des/descert.c'\"
  1120. else
  1121. echo shar: Extracting \"'des/descert.c'\" \(1356 characters\)
  1122. sed "s/^X//" >'des/descert.c' <<'END_OF_FILE'
  1123. X/*
  1124. X * $Id: descert.c,v 2.0.1.1 91/04/01 15:39:44 ram Exp $
  1125. X *
  1126. X * $Log:    descert.c,v $
  1127. X * Revision 2.0.1.1  91/04/01  15:39:44  ram
  1128. X * patch1: created
  1129. X * 
  1130. X */
  1131. X
  1132. X#include <stdio.h>
  1133. int nfail = 0;
  1134. main()
  1135. X{
  1136. X    char key[8],plain[8],cipher[8],answer[8];
  1137. X    int i;
  1138. X    int test;
  1139. X    int fail;
  1140. X
  1141. X    desinit(0);
  1142. X
  1143. X    for(test=0;!feof(stdin);test++){
  1144. X
  1145. X        get8(key);
  1146. X        printf(" K: "); put8(key);
  1147. X        setkey(key);
  1148. X
  1149. X        get8(plain);
  1150. X        printf(" P: "); put8(plain);
  1151. X
  1152. X        get8(answer);
  1153. X        printf(" C: "); put8(answer);
  1154. X
  1155. X        for(i=0;i<8;i++)
  1156. X            cipher[i] = plain[i];
  1157. X        endes(cipher);
  1158. X
  1159. X        for(i=0;i<8;i++)
  1160. X            if(cipher[i] != answer[i])
  1161. X                break;
  1162. X        fail = 0;
  1163. X        if(i != 8){
  1164. X            printf(" Encrypt FAIL");
  1165. X            fail++;
  1166. X        }
  1167. X        dedes(cipher);
  1168. X        for(i=0;i<8;i++)
  1169. X            if(cipher[i] != plain[i])
  1170. X                break;
  1171. X        if(i != 8){
  1172. X            printf(" Decrypt FAIL");
  1173. X            fail++;
  1174. X        }
  1175. X        if(fail == 0)
  1176. X            printf(" OK");
  1177. X        else
  1178. X            nfail++;
  1179. X        printf("\n");
  1180. X    }
  1181. X
  1182. X    stats();
  1183. X    /* NOTREACHED */
  1184. X}
  1185. X
  1186. stats()
  1187. X{
  1188. X    printf("\n    -- ");
  1189. X    if (nfail == 0)
  1190. X        printf("All tests succesful");
  1191. X    else if (nfail == 1)
  1192. X        printf("FAILED 1 test");
  1193. X    else
  1194. X        printf("FAILED %d tests", nfail);
  1195. X    printf(".\n\n");
  1196. X    (void) exit((nfail == 0)? 0 : 1);
  1197. X    /* NOTREACHED */
  1198. X}
  1199. X
  1200. get8(cp)
  1201. char *cp;
  1202. X{
  1203. X    int i,t;
  1204. X
  1205. X    for(i=0;i<8;i++){
  1206. X        scanf("%2x",&t);
  1207. X        if(feof(stdin))
  1208. X            stats();
  1209. X        *cp++ = t;
  1210. X    }
  1211. X}
  1212. put8(cp)
  1213. char *cp;
  1214. X{
  1215. X    int i;
  1216. X
  1217. X    for(i=0;i<8;i++){
  1218. X        printf("%02x",*cp++ & 0xff);
  1219. X    }
  1220. X}
  1221. END_OF_FILE
  1222. if test 1356 -ne `wc -c <'des/descert.c'`; then
  1223.     echo shar: \"'des/descert.c'\" unpacked with wrong size!
  1224. fi
  1225. # end of 'des/descert.c'
  1226. fi
  1227. if test -f 'des/getopt.c' -a "${1}" != "-c" ; then 
  1228.   echo shar: Will not clobber existing file \"'des/getopt.c'\"
  1229. else
  1230. echo shar: Extracting \"'des/getopt.c'\" \(1639 characters\)
  1231. sed "s/^X//" >'des/getopt.c' <<'END_OF_FILE'
  1232. X/* got this off net.sources */
  1233. X/*
  1234. X * $Id: getopt.c,v 2.0.1.1 91/04/01 15:39:52 ram Exp $
  1235. X *
  1236. X * $Log:    getopt.c,v $
  1237. X * Revision 2.0.1.1  91/04/01  15:39:52  ram
  1238. X * patch1: created
  1239. X * 
  1240. X */
  1241. X
  1242. X#include "../config.h"
  1243. X#ifndef GETOPT
  1244. X#include <stdio.h>
  1245. X
  1246. X/*
  1247. X * get option letter from argument vector
  1248. X */
  1249. int    opterr = 1,        /* useless, never set or used */
  1250. X    optind = 1,        /* index into parent argv vector */
  1251. X    optopt;            /* character checked for validity */
  1252. char    *optarg;        /* argument associated with option */
  1253. X
  1254. X#define BADCH    (int)'?'
  1255. X#define EMSG    ""
  1256. X#define tell(s)    fputs(*nargv,stderr);fputs(s,stderr); \
  1257. X        fputc(optopt,stderr);fputc('\n',stderr);return(BADCH);
  1258. X
  1259. getopt(nargc,nargv,ostr)
  1260. int    nargc;
  1261. char    **nargv,
  1262. X    *ostr;
  1263. X{
  1264. X    static char    *place = EMSG;    /* option letter processing */
  1265. X    register char    *oli;        /* option letter list index */
  1266. X    char    *index();
  1267. X
  1268. X    if(!*place) {            /* update scanning pointer */
  1269. X        if(optind >= nargc || *(place = nargv[optind]) != '-' || !*++place) return(EOF);
  1270. X        if (*place == '-') {    /* found "--" */
  1271. X            ++optind;
  1272. X            return(EOF);
  1273. X        }
  1274. X    }                /* option letter okay? */
  1275. X    if ((optopt = (int)*place++) == (int)':' || !(oli = index(ostr,optopt))) {
  1276. X        if(!*place) ++optind;
  1277. X        tell(": illegal option -- ");
  1278. X    }
  1279. X    if (*++oli != ':') {        /* don't need argument */
  1280. X        optarg = NULL;
  1281. X        if (!*place) ++optind;
  1282. X    }
  1283. X    else {                /* need an argument */
  1284. X        if (*place) optarg = place;    /* no white space */
  1285. X        else if (nargc <= ++optind) {    /* no arg */
  1286. X            place = EMSG;
  1287. X            tell(": option requires an argument -- ");
  1288. X        }
  1289. X         else optarg = nargv[optind];    /* white space */
  1290. X        place = EMSG;
  1291. X        ++optind;
  1292. X    }
  1293. X    return(optopt);            /* dump back option letter */
  1294. X}
  1295. X#endif
  1296. X
  1297. END_OF_FILE
  1298. if test 1639 -ne `wc -c <'des/getopt.c'`; then
  1299.     echo shar: \"'des/getopt.c'\" unpacked with wrong size!
  1300. fi
  1301. # end of 'des/getopt.c'
  1302. fi
  1303. if test -f 'des/getpass.c' -a "${1}" != "-c" ; then 
  1304.   echo shar: Will not clobber existing file \"'des/getpass.c'\"
  1305. else
  1306. echo shar: Extracting \"'des/getpass.c'\" \(2184 characters\)
  1307. sed "s/^X//" >'des/getpass.c' <<'END_OF_FILE'
  1308. X/*
  1309. X * $Id: getpass.c,v 2.0.1.2 91/04/30 13:33:30 ram Exp $
  1310. X *
  1311. X * $Log:    getpass.c,v $
  1312. X * Revision 2.0.1.2  91/04/30  13:33:30  ram
  1313. X * patch3: now relies on the new metaconfig symbol SIGNAL_T
  1314. X * 
  1315. X * Revision 2.0.1.1  91/04/01  15:40:01  ram
  1316. X * patch1: created
  1317. X * 
  1318. X */
  1319. X
  1320. X#include <stdio.h>
  1321. X#include <signal.h>
  1322. X#include "../config.h"
  1323. X
  1324. X/* These defines should be correctly set up by Configure */
  1325. X#ifdef I_TERMIOS
  1326. X#include <termios.h>
  1327. X#endif
  1328. X#ifdef I_TERMIO
  1329. X#include <termio.h>
  1330. X#endif
  1331. X#ifdef I_SGTTY
  1332. X#include <sgtty.h>
  1333. X#endif
  1334. X#ifdef I_SYSIOCTL
  1335. X#include <sys/ioctl.h>
  1336. X#endif
  1337. X
  1338. X#define    TTY    "/dev/tty"    /* Change to "con" for MS-DOS */
  1339. X
  1340. X/* Issue prompt and read reply with echo turned off */
  1341. char *
  1342. getpass(prompt)
  1343. char *prompt;
  1344. X{
  1345. X    register char *cp;
  1346. X    int c;
  1347. X    FILE *tty;
  1348. X    static char pbuf[128];
  1349. X
  1350. X#ifdef I_SGTTY
  1351. X    struct sgttyb ttyb,ttysav;
  1352. X#else
  1353. X#ifdef I_TERMIOS
  1354. X    struct termios ttyb, ttysav;
  1355. X#else
  1356. X    struct termio ttyb, ttysav;
  1357. X#endif
  1358. X#endif
  1359. X
  1360. X    extern SIGNAL_T (*signal())();
  1361. X    SIGNAL_T (*sig)();
  1362. X
  1363. X    if ((tty = fdopen(open(TTY, 2), "r")) == NULL)
  1364. X        tty = stdin;
  1365. X    else
  1366. X        setbuf(tty, (char *)NULL);
  1367. X    sig = signal(SIGINT, SIG_IGN);
  1368. X
  1369. X#ifdef I_SGTTY
  1370. X    ioctl(fileno(tty), TIOCGETP, &ttyb);
  1371. X    ioctl(fileno(tty), TIOCGETP, &ttysav);
  1372. X    ttyb.sg_flags |= RAW;
  1373. X    ttyb.sg_flags &= ~ECHO;
  1374. X    ioctl(fileno(tty), TIOCSETP, &ttyb);
  1375. X#else
  1376. X#ifdef I_TERMIOS
  1377. X    tcgetattr(fileno(tty), &ttyb);
  1378. X    tcgetattr(fileno(tty), &ttysav);
  1379. X#else
  1380. X    ioctl(fileno(tty), TCGETA, &ttyb);
  1381. X    ioctl(fileno(tty), TCGETA, &ttysav);
  1382. X#endif
  1383. X#ifdef CBREAK
  1384. X    ttyb.c_lflag |= CBREAK;
  1385. X#endif
  1386. X#ifdef RAW
  1387. X    ttyb.c_lflag |= RAW;
  1388. X#endif
  1389. X    ttyb.c_lflag &= ~ECHO;
  1390. X#ifdef I_TERMIOS
  1391. X    tcsetattr(fileno(tty), TCSANOW, &ttyb);
  1392. X#else
  1393. X    ioctl(fileno(tty), TCSETA, &ttyb);
  1394. X#endif
  1395. X#endif
  1396. X
  1397. X    fprintf(stderr, "%s", prompt);
  1398. X    fflush(stderr);
  1399. X    cp = pbuf;
  1400. X    for (;;) {
  1401. X        c = getc(tty);
  1402. X        if(c == '\r' || c == '\n' || c == EOF)
  1403. X            break;
  1404. X        if (cp < &pbuf[127])
  1405. X            *cp++ = c;
  1406. X    }
  1407. X    *cp = '\0';
  1408. X    fprintf(stderr,"\r\n");
  1409. X    fflush(stderr);
  1410. X
  1411. X#ifdef I_SGTTY
  1412. X    ioctl(fileno(tty), TIOCSETP, &ttysav);
  1413. X#else
  1414. X#ifdef I_TERMIOS
  1415. X    tcsetattr(fileno(tty), TCSANOW, &ttysav);
  1416. X#else
  1417. X    ioctl(fileno(tty), TCSETA, &ttysav);
  1418. X#endif
  1419. X#endif
  1420. X
  1421. X    signal(SIGINT, sig);
  1422. X    if (tty != stdin)
  1423. X        fclose(tty);
  1424. X    return(pbuf);
  1425. X}
  1426. END_OF_FILE
  1427. if test 2184 -ne `wc -c <'des/getpass.c'`; then
  1428.     echo shar: \"'des/getpass.c'\" unpacked with wrong size!
  1429. fi
  1430. # end of 'des/getpass.c'
  1431. fi
  1432. if test -f 'des/misc.c' -a "${1}" != "-c" ; then 
  1433.   echo shar: Will not clobber existing file \"'des/misc.c'\"
  1434. else
  1435. echo shar: Extracting \"'des/misc.c'\" \(526 characters\)
  1436. sed "s/^X//" >'des/misc.c' <<'END_OF_FILE'
  1437. X/*
  1438. X * $Id: misc.c,v 2.0.1.1 91/04/01 15:40:18 ram Exp $
  1439. X *
  1440. X * $Log:    misc.c,v $
  1441. X * Revision 2.0.1.1  91/04/01  15:40:18  ram
  1442. X * patch1: created
  1443. X * 
  1444. X */
  1445. X
  1446. X#include "../config.h"
  1447. X#ifndef MEMSET
  1448. X/* Set block of memory to constant */
  1449. memset(blk,val,size)
  1450. register char *blk;
  1451. register char val;
  1452. register unsigned size;
  1453. X{
  1454. X    while(size-- != 0)
  1455. X        *blk++ = val;
  1456. X}
  1457. X#endif
  1458. X
  1459. X#ifndef MEMCPY
  1460. X/* Copy block of memory */
  1461. memcpy(dest,src,size)
  1462. register char *dest,*src;
  1463. register unsigned size;
  1464. X{
  1465. X    while(size-- != 0)
  1466. X        *dest++ = *src++;
  1467. X}
  1468. X#endif
  1469. X
  1470. END_OF_FILE
  1471. if test 526 -ne `wc -c <'des/misc.c'`; then
  1472.     echo shar: \"'des/misc.c'\" unpacked with wrong size!
  1473. fi
  1474. # end of 'des/misc.c'
  1475. fi
  1476. if test -f 'des/testdata' -a "${1}" != "-c" ; then 
  1477.   echo shar: Will not clobber existing file \"'des/testdata'\"
  1478. else
  1479. echo shar: Extracting \"'des/testdata'\" \(1734 characters\)
  1480. sed "s/^X//" >'des/testdata' <<'END_OF_FILE'
  1481. X0000000000000000 0000000000000000 8CA64DE9C1B123A7
  1482. XFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF 7359B2163E4EDC58
  1483. X3000000000000000 1000000000000001 958E6E627A05557B
  1484. X1111111111111111 1111111111111111 F40379AB9E0EC533
  1485. X0123456789ABCDEF 1111111111111111 17668DFC7292532D
  1486. X1111111111111111 0123456789ABCDEF 8A5AE1F81AB8F2DD
  1487. X0000000000000000 0000000000000000 8CA64DE9C1B123A7
  1488. XFEDCBA9876543210 0123456789ABCDEF ED39D950FA74BCC4
  1489. X7CA110454A1A6E57 01A1D6D039776742 690F5B0D9A26939B
  1490. X0131D9619DC1376E 5CD54CA83DEF57DA 7A389D10354BD271
  1491. X07A1133E4A0B2686 0248D43806F67172 868EBB51CAB4599A
  1492. X3849674C2602319E 51454B582DDF440A 7178876E01F19B2A
  1493. X04B915BA43FEB5B6 42FD443059577FA2 AF37FB421F8C4095
  1494. X0113B970FD34F2CE 059B5E0851CF143A 86A560F10EC6D85B
  1495. X0170F175468FB5E6 0756D8E0774761D2 0CD3DA020021DC09
  1496. X43297FAD38E373FE 762514B829BF486A EA676B2CB7DB2B7A
  1497. X07A7137045DA2A16 3BDD119049372802 DFD64A815CAF1A0F
  1498. X04689104C2FD3B2F 26955F6835AF609A 5C513C9C4886C088
  1499. X37D06BB516CB7546 164D5E404F275232 0A2AEEAE3FF4AB77
  1500. X1F08260D1AC2465E 6B056E18759F5CCA EF1BF03E5DFA575A
  1501. X584023641ABA6176 004BD6EF09176062 88BF0DB6D70DEE56
  1502. X025816164629B007 480D39006EE762F2 A1F9915541020B56
  1503. X49793EBC79B3258F 437540C8698F3CFA 6FBF1CAFCFFD0556
  1504. X4FB05E1515AB73A7 072D43A077075292 2F22E49BAB7CA1AC
  1505. X49E95D6D4CA229BF 02FE55778117F12A 5A6B612CC26CCE4A
  1506. X018310DC409B26D6 1D9D5C5018F728C2 5F4C038ED12B2E41
  1507. X1C587F1C13924FEF 305532286D6F295A 63FAC0D034D9F793
  1508. X0101010101010101 0123456789ABCDEF 617B3A0CE8F07100
  1509. X1F1F1F1F0E0E0E0E 0123456789ABCDEF DB958605F8C8C606
  1510. XE0FEE0FEF1FEF1FE 0123456789ABCDEF EDBFD1C66C29CCC7
  1511. X0000000000000000 FFFFFFFFFFFFFFFF 355550B2150E2451
  1512. XFFFFFFFFFFFFFFFF 0000000000000000 CAAAAF4DEAF1DBAE
  1513. X0123456789ABCDEF 0000000000000000 D5D44FF720683D0D
  1514. XFEDCBA9876543210 FFFFFFFFFFFFFFFF 2A2BB008DF97C2F2
  1515. END_OF_FILE
  1516. if test 1734 -ne `wc -c <'des/testdata'`; then
  1517.     echo shar: \"'des/testdata'\" unpacked with wrong size!
  1518. fi
  1519. # end of 'des/testdata'
  1520. fi
  1521. if test -f 'install.SH' -a "${1}" != "-c" ; then 
  1522.   echo shar: Will not clobber existing file \"'install.SH'\"
  1523. else
  1524. echo shar: Extracting \"'install.SH'\" \(3781 characters\)
  1525. sed "s/^X//" >'install.SH' <<'END_OF_FILE'
  1526. case $CONFIG in
  1527. X'')
  1528. X    if test ! -f config.sh; then
  1529. X        ln ../config.sh . || \
  1530. X        ln ../../config.sh . || \
  1531. X        ln ../../../config.sh . || \
  1532. X        (echo "Can't find config.sh."; exit 1)
  1533. X    fi 2>/dev/null
  1534. X    . config.sh
  1535. X    ;;
  1536. esac
  1537. case "$0" in
  1538. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  1539. esac
  1540. echo "Extracting install (with variable substitutions)"
  1541. X$spitshell >install <<!GROK!THIS!
  1542. X$startsh
  1543. X# @(#) Installing script accepting bsd-style arguments
  1544. X# Derived from a script found in the X11R4 distribution.
  1545. X
  1546. X# $Id: install.SH,v 2.0.1.2 91/07/30 17:20:35 ram Exp $
  1547. X#
  1548. X# $Log:    install.SH,v $
  1549. X# Revision 2.0.1.2  91/07/30  17:20:35  ram
  1550. X# patch6: new install.SH script
  1551. X# 
  1552. X# Revision 2.0.1.1  91/05/27  14:20:35  ram
  1553. X# patch5: mkdir_p is now eval'ed instead of being a function
  1554. X# patch5: explicitely exit with a zero status when all is done
  1555. X# 
  1556. X# Revision 2.0  91/02/19  15:49:42  ram
  1557. X# Baseline for first official release.
  1558. X# 
  1559. X
  1560. chown='$chown'
  1561. chmod='$chmod'
  1562. chgrp='$chgrp'
  1563. rm='$rm'
  1564. mv='$mv'
  1565. test='$test'
  1566. sed='$sed'
  1567. X!GROK!THIS!
  1568. X$spitshell >>install <<'!NO!SUBS!'
  1569. X
  1570. mode=""
  1571. dst=""
  1572. src=""
  1573. dostrip=""
  1574. newdir=""
  1575. uid=""
  1576. gid=""
  1577. X
  1578. X# simulates mkdir -p
  1579. mkdir_p='
  1580. name=$1;
  1581. create='';
  1582. while $test $name; do
  1583. X    if $test ! -d "$name"; then
  1584. X        create="$name $create";
  1585. X        name=`echo $name | $sed -e "s|^[^/]*$||"`;
  1586. X        name=`echo $name | $sed -e "s|\(.*\)/.*|\1|"`;
  1587. X    else
  1588. X        name='';
  1589. X    fi;
  1590. done;
  1591. for file in $create; do
  1592. X    mkdir $file && $test $verbose &&
  1593. X    echo "install: created directory $file" >&2;
  1594. done
  1595. X'
  1596. X
  1597. verbose=''
  1598. X
  1599. while $test x$1 != x
  1600. do
  1601. X    case $1 in 
  1602. X    -c) shift
  1603. X        continue
  1604. X        ;;
  1605. X    -m) mode="$2 "
  1606. X        shift
  1607. X        shift
  1608. X        continue
  1609. X        ;;
  1610. X    -o) uid="$2 "
  1611. X        shift
  1612. X        shift
  1613. X        continue
  1614. X        ;;
  1615. X    -g) gid="$2 "
  1616. X        shift
  1617. X        shift
  1618. X        continue
  1619. X        ;;
  1620. X    -s) dostrip="strip"
  1621. X        shift
  1622. X        continue
  1623. X        ;;
  1624. X    -d) newdir="$newdir$2 "
  1625. X        shift
  1626. X        shift
  1627. X        continue
  1628. X        ;;
  1629. X    -v) verbose='true'
  1630. X        shift
  1631. X        ;;
  1632. X    *) if $test x$src = x
  1633. X        then
  1634. X            src=$1
  1635. X        else
  1636. X            dst=$1
  1637. X        fi
  1638. X        shift
  1639. X        continue
  1640. X        ;;
  1641. X    esac
  1642. done
  1643. X
  1644. X# if -d option is used, we have to create the path given
  1645. if $test ! x$newdir = x
  1646. then
  1647. X    for i in $newdir
  1648. X    do
  1649. X        set x $i
  1650. X        shift
  1651. X        eval $mkdir_p
  1652. X    done
  1653. X    exit 0        # -d is the only action
  1654. fi
  1655. X
  1656. if $test x$src = x
  1657. then
  1658. X    echo "install: no input file specified" >&2
  1659. X    exit 1
  1660. fi
  1661. X
  1662. if $test x$dst = x
  1663. then
  1664. X    echo "install: no destination specified" >&2
  1665. X    exit 1
  1666. fi
  1667. X
  1668. srcbase=`basename $src`
  1669. dstbase=`basename $dst`
  1670. X
  1671. X# If the destination is a directory, the target name is srcbase...
  1672. if $test -d $dst; then
  1673. X    dstbase=$srcbase
  1674. else
  1675. X    dst="`echo $dst | sed 's,^\(.*\)/.*$,\1,'`"
  1676. X    if $test ! -d $dst; then
  1677. X        dstbase=$dst
  1678. X        dst="."
  1679. X    fi
  1680. fi
  1681. X
  1682. X# If the src has a directory, extract the dir name...
  1683. if $test "$src" != "$srcbase" -a "$src" != "./$srcbase"; then
  1684. X    src="`echo $src | sed 's,^\(.*\)/.*$,\1,'`"
  1685. else
  1686. X    src="."
  1687. fi
  1688. X
  1689. X# dst is the destination directory and dstbase the base name.
  1690. X# srcbase is the base name of source and src the source dir.
  1691. X
  1692. srcpth=`(cd $src; pwd)`/$srcbase
  1693. destpth=`(cd $dst; pwd)`/$dstbase
  1694. if $test x$srcpth = x$destpth; then
  1695. X    $test $verbose && \
  1696. X    echo "install: destination and source are identical"
  1697. X    exit 0
  1698. fi
  1699. X
  1700. X# Do the install
  1701. X(
  1702. X    cd $src
  1703. X
  1704. X    if $test -f $dst/$dstbase; then
  1705. X        $rm -f $dst/$dstbase && $test $verbose &&
  1706. X        echo "install: $dst/$dstbase removed"
  1707. X    fi
  1708. X    if $test -f $dst/$dstbase; then
  1709. X        $mv $dst/$dstbase $dst/OLD$dstbase && $test $verbose &&
  1710. X        echo "install: $dst/$dstbase renamed as OLD$dstbase"
  1711. X    fi
  1712. X
  1713. X    cp $srcbase $dst/$dstbase && $test $verbose &&
  1714. X    echo "install: $srcbase installed as $dst/$dstbase"
  1715. X
  1716. X    if $test ! x$dostrip = x; then
  1717. X        strip $dst/$dstbase 2>/dev/null && $test $verbose &&
  1718. X        echo "install: stripped $dst/$dstbase"
  1719. X    fi
  1720. X
  1721. X    if $test ! x$uid = x; then
  1722. X        $chown $uid $dst/$dstbase
  1723. X    fi
  1724. X    if $test ! x$gid = x; then
  1725. X        $chgrp $gid $dst/$dstbase
  1726. X    fi
  1727. X    if $test ! x$mode = x
  1728. X    then
  1729. X        $chmod $mode $dst/$dstbase
  1730. X    fi
  1731. X)
  1732. X
  1733. exit 0
  1734. X!NO!SUBS!
  1735. chmod 755 install
  1736. X$eunicefix install
  1737. END_OF_FILE
  1738. if test 3781 -ne `wc -c <'install.SH'`; then
  1739.     echo shar: \"'install.SH'\" unpacked with wrong size!
  1740. fi
  1741. chmod +x 'install.SH'
  1742. # end of 'install.SH'
  1743. fi
  1744. if test ! -d 'kit' ; then
  1745.     echo shar: Creating directory \"'kit'\"
  1746.     mkdir 'kit'
  1747. fi
  1748. if test -f 'kit/Makefile.SH' -a "${1}" != "-c" ; then 
  1749.   echo shar: Will not clobber existing file \"'kit/Makefile.SH'\"
  1750. else
  1751. echo shar: Extracting \"'kit/Makefile.SH'\" \(1430 characters\)
  1752. sed "s/^X//" >'kit/Makefile.SH' <<'END_OF_FILE'
  1753. case $CONFIG in
  1754. X'')
  1755. X    if test ! -f config.sh; then
  1756. X        ln ../config.sh . || \
  1757. X        ln ../../config.sh . || \
  1758. X        ln ../../../config.sh . || \
  1759. X        (echo "Can't find config.sh."; exit 1)
  1760. X    fi
  1761. X    . config.sh
  1762. X    ;;
  1763. esac
  1764. case "$0" in
  1765. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  1766. esac
  1767. echo "Extracting kit/Makefile (with variable substitutions)"
  1768. X$spitshell >Makefile <<!GROK!THIS!
  1769. X#
  1770. X# Makefile for kit (sub-directory kit)
  1771. X#
  1772. X
  1773. X# $Id: Makefile.SH,v 2.0.1.3 91/11/25 15:49:18 ram Exp $
  1774. X#
  1775. X# $Log:    Makefile.SH,v $
  1776. X# Revision 2.0.1.3  91/11/25  15:49:18  ram
  1777. X# patch9: now installs minikit in the private kit library
  1778. X# 
  1779. X# Revision 2.0.1.2  91/11/25  12:03:28  ram
  1780. X# patch8: this file was stamped with a wrong package name
  1781. X# 
  1782. X# Revision 2.0.1.1  91/05/27  14:21:28  ram
  1783. X# patch5: some dumb make failed on previous makefile
  1784. X# 
  1785. X# Revision 2.0  91/02/19  15:49:49  ram
  1786. X# Baseline for first official release.
  1787. X# 
  1788. X
  1789. SHELL = /bin/sh
  1790. X
  1791. RM = $rm
  1792. binsh = $scriptdir
  1793. libdir = $privlib
  1794. X
  1795. X!GROK!THIS!
  1796. X$spitshell >>Makefile <<'!NO!SUBS!'
  1797. scripts = kit mailkit unkit
  1798. scriptsh = kit.SH mailkit.SH unkit.SH
  1799. added = Makefile config.sh
  1800. X
  1801. all: $(scripts)
  1802. X
  1803. kit: kit.SH
  1804. X    sh $@.SH
  1805. X
  1806. mailkit: mailkit.SH
  1807. X    sh $@.SH
  1808. X
  1809. unkit: unkit.SH
  1810. X    sh $@.SH
  1811. X
  1812. install: $(scripts)
  1813. X    -for file in $(scripts); do \
  1814. X        ../install -m 755 $$file $(binsh); \
  1815. X    done
  1816. X    ../install -m 644 minikit $(libdir)
  1817. X
  1818. clean:
  1819. X    $(RM) -f $(scripts)
  1820. X
  1821. realclean clobber: clean
  1822. X    $(RM) -f $(added)
  1823. X!NO!SUBS!
  1824. chmod 755 Makefile
  1825. X$eunicefix Makefile
  1826. END_OF_FILE
  1827. if test 1430 -ne `wc -c <'kit/Makefile.SH'`; then
  1828.     echo shar: \"'kit/Makefile.SH'\" unpacked with wrong size!
  1829. fi
  1830. chmod +x 'kit/Makefile.SH'
  1831. # end of 'kit/Makefile.SH'
  1832. fi
  1833. if test -f 'kit/minikit' -a "${1}" != "-c" ; then 
  1834.   echo shar: Will not clobber existing file \"'kit/minikit'\"
  1835. else
  1836. echo shar: Extracting \"'kit/minikit'\" \(3119 characters\)
  1837. sed "s/^X//" >'kit/minikit' <<'END_OF_FILE'
  1838. X#! /bin/sh
  1839. export PATH || exec sh $0
  1840. trap "rm -f mini_unkit mini_code.c core mini_code; exit 1" 1 2 3 15
  1841. echo "Extracting mini kit..."
  1842. cat >mini_code.c <<'EOP'
  1843. X#include <stdio.h>
  1844. X#define reg register
  1845. X#define streq(s0, s1)  strcmp(s0, s1) == 0
  1846. X#define times85(x)    ((((((x<<2)+x)<<2)+x)<<2)+x)
  1847. X#define DE(c) ((c) - '!')
  1848. long int Ceor = 0;
  1849. long int Csum = 0;
  1850. long int Crot = 0;
  1851. long int word = 0;
  1852. long int bcount = 0;
  1853. fatal() {
  1854. X  fprintf(stderr, "bad format or Csum to atob\n");
  1855. X  exit(1);
  1856. X}
  1857. error(s) char *s;
  1858. X{
  1859. X  fprintf(stderr, "%s\n", s);
  1860. X  exit(1);
  1861. X}
  1862. decode(c) reg c;
  1863. X{
  1864. X  if (c == 'z') {
  1865. X    if (bcount != 0) {
  1866. X      fatal();
  1867. X    } 
  1868. X    else {
  1869. X      byteout(0); byteout(0); byteout(0); byteout(0);
  1870. X    }
  1871. X  } 
  1872. X  else if ((c >= '!') && (c < ('!' + 85))) {
  1873. X    if (bcount == 0) {
  1874. X      word = DE(c);
  1875. X      ++bcount;
  1876. X    } 
  1877. X    else if (bcount < 4) {
  1878. X      word = times85(word);
  1879. X      word += DE(c);
  1880. X      ++bcount;
  1881. X    } 
  1882. X    else {
  1883. X      word = times85(word) + DE(c);
  1884. X      byteout((int)((word >> 24) & 255));
  1885. X      byteout((int)((word >> 16) & 255));
  1886. X      byteout((int)((word >> 8) & 255));
  1887. X      byteout((int)(word & 255));
  1888. X      word = 0;
  1889. X      bcount = 0;
  1890. X    }
  1891. X  } 
  1892. X  else {
  1893. X    fatal();
  1894. X  }
  1895. X}
  1896. XFILE *tmp_file;
  1897. byteout(c) reg c;
  1898. X{
  1899. X  Ceor ^= c;
  1900. X  Csum += c;
  1901. X  Csum += 1;
  1902. X  if ((Crot & 0x80000000)) {
  1903. X    Crot <<= 1;
  1904. X    Crot += 1;
  1905. X  } 
  1906. X  else {
  1907. X    Crot <<= 1;
  1908. X  }
  1909. X  Crot += c;
  1910. X  putc(c, tmp_file);
  1911. X}
  1912. main(argc, argv) char **argv;
  1913. X{
  1914. X  reg c;
  1915. X  reg long int i;
  1916. X  char tmp_name[100];
  1917. X  char buf[100];
  1918. X  long int n1, n2, oeor, osum, orot;
  1919. X
  1920. X  if (argc != 1) {
  1921. X    fprintf(stderr,"bad args to %s\n", argv[0]);
  1922. X    exit(2);
  1923. X  }
  1924. X  sprintf(tmp_name, "/usr/tmp/atob.%x", getpid());
  1925. X  tmp_file = fopen(tmp_name, "w+");
  1926. X  if (tmp_file == NULL) {
  1927. X    error("can't create temporary file");
  1928. X  }
  1929. X  unlink(tmp_name);
  1930. X  for (;;) {
  1931. X    if (fgets(buf, sizeof buf, stdin) == NULL) {
  1932. X      error("could not read header line");
  1933. X    }
  1934. X    if (streq(buf, "xbtoa Begin\n")) {
  1935. X      break;
  1936. X    }
  1937. X  }
  1938. X
  1939. X  while ((c = getchar()) != EOF) {
  1940. X    if (c == '\n') {
  1941. X      continue;
  1942. X    } 
  1943. X    else if (c == 'x') {
  1944. X      break;
  1945. X    } 
  1946. X    else {
  1947. X      decode(c);
  1948. X    }
  1949. X  }
  1950. X  if (scanf("btoa End N %ld %lx E %lx S %lx R %lx\n", &n1, &n2, &oeor, &osum, &orot) != 5) {
  1951. X    error("could not read check sum");
  1952. X  }
  1953. X  if ((n1 != n2) || (oeor != Ceor) || (osum != Csum) || (orot != Crot)) {
  1954. X    fatal();
  1955. X  } 
  1956. X  else {
  1957. X    fseek(tmp_file, 0L, 0);
  1958. X    for (i = n1; --i >= 0;) {
  1959. X      putchar(getc(tmp_file));
  1960. X    }
  1961. X  }
  1962. X  exit(0);
  1963. X}
  1964. XEOP
  1965. cat >mini_unkit <<'EOP'
  1966. if tar -cf - /dev/null 2>/dev/null | tar -xof - >/dev/null 2>&1; then
  1967. X    tar_opt='xvof'
  1968. else
  1969. X    tar_opt='xvf'
  1970. fi
  1971. if test -f zag.ba.aa; then
  1972. X    cat `ls zag.ba.??` | ./mini_code | zcat | tar $tar_opt - || exit 1
  1973. else
  1974. X    echo >&2 "Sorry, I can only deal with plain ascii-encoded kits"
  1975. X    exit 1
  1976. fi
  1977. test -f zzz.minikit && rm -f `cat zzz.minikit` zzz.minikit
  1978. rm -f z??.[hb][ea]*.??
  1979. XEOP
  1980. echo "Compiling mini kit..."
  1981. if cc -o mini_code mini_code.c >/dev/null 2>&1; then
  1982. X    echo "Running mini kit..."
  1983. X    sh mini_unkit
  1984. else
  1985. X    echo "Error in C compilation--aborting."
  1986. fi
  1987. rm -f core mini_code mini_code.c mini_unkit
  1988. echo "Done."
  1989. END_OF_FILE
  1990. if test 3119 -ne `wc -c <'kit/minikit'`; then
  1991.     echo shar: \"'kit/minikit'\" unpacked with wrong size!
  1992. fi
  1993. # end of 'kit/minikit'
  1994. fi
  1995. if test ! -d 'man' ; then
  1996.     echo shar: Creating directory \"'man'\"
  1997.     mkdir 'man'
  1998. fi
  1999. if test -f 'man/Makefile.SH' -a "${1}" != "-c" ; then 
  2000.   echo shar: Will not clobber existing file \"'man/Makefile.SH'\"
  2001. else
  2002. echo shar: Extracting \"'man/Makefile.SH'\" \(1278 characters\)
  2003. sed "s/^X//" >'man/Makefile.SH' <<'END_OF_FILE'
  2004. case $CONFIG in
  2005. X'')
  2006. X    if test ! -f config.sh; then
  2007. X        ln ../config.sh . || \
  2008. X        ln ../../config.sh . || \
  2009. X        ln ../../../config.sh . || \
  2010. X        (echo "Can't find config.sh."; exit 1)
  2011. X    fi 2>/dev/null
  2012. X    . config.sh
  2013. X    ;;
  2014. esac
  2015. case "$0" in
  2016. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  2017. esac
  2018. echo "Extracting man/Makefile (with variable substitutions)"
  2019. X$spitshell >Makefile <<!GROK!THIS!
  2020. X#
  2021. X# Makefile for kit (sub-directory man)
  2022. X#
  2023. X
  2024. X# $Id: Makefile.SH,v 2.0.1.2 91/05/27 14:30:53 ram Exp $
  2025. X#
  2026. X# $Log:    Makefile.SH,v $
  2027. X# Revision 2.0.1.2  91/05/27  14:30:53  ram
  2028. X# patch5: search for config.sh is now silent
  2029. X# 
  2030. X# Revision 2.0.1.1  91/04/30  13:35:12  ram
  2031. X# patch3: installation of manual pages made optional
  2032. X# 
  2033. X# Revision 2.0  91/02/19  15:50:12  ram
  2034. X# Baseline for first official release.
  2035. X# 
  2036. X
  2037. SHELL = /bin/sh
  2038. X
  2039. RM = $rm
  2040. man = $mansrc
  2041. X
  2042. X.SUFFIXES: .$manext .SH
  2043. X
  2044. X.SH.$manext:
  2045. X    sh $<
  2046. X
  2047. L = $manext
  2048. X!GROK!THIS!
  2049. X$spitshell >>Makefile <<'!NO!SUBS!'
  2050. manpage = atob.$(L) btoa.$(L) kit.$(L) mailkit.$(L) unkit.$(L)
  2051. added = Makefile config.sh
  2052. X
  2053. X.SH:
  2054. X    sh $<
  2055. X
  2056. all: $(manpage)
  2057. X
  2058. install: all
  2059. X    -if test "$(man)"; then \
  2060. X        for file in $(manpage); do \
  2061. X            ../install -m 444 $$file $(man); \
  2062. X        done; \
  2063. X    fi
  2064. X
  2065. clean:
  2066. X    $(RM) -f $(manpage)
  2067. X
  2068. realclean clobber: clean
  2069. X    $(RM) -f $(added)
  2070. X!NO!SUBS!
  2071. chmod 755 Makefile
  2072. X$eunicefix Makefile
  2073. END_OF_FILE
  2074. if test 1278 -ne `wc -c <'man/Makefile.SH'`; then
  2075.     echo shar: \"'man/Makefile.SH'\" unpacked with wrong size!
  2076. fi
  2077. chmod +x 'man/Makefile.SH'
  2078. # end of 'man/Makefile.SH'
  2079. fi
  2080. if test -f 'man/atob.SH' -a "${1}" != "-c" ; then 
  2081.   echo shar: Will not clobber existing file \"'man/atob.SH'\"
  2082. else
  2083. echo shar: Extracting \"'man/atob.SH'\" \(450 characters\)
  2084. sed "s/^X//" >'man/atob.SH' <<'END_OF_FILE'
  2085. case $CONFIG in
  2086. X'')
  2087. X    if test ! -f config.sh; then
  2088. X        ln ../config.sh . || \
  2089. X        ln ../../config.sh . || \
  2090. X        ln ../../../config.sh . || \
  2091. X        (echo "Can't find config.sh."; exit 1)
  2092. X    fi 2>/dev/null
  2093. X    . config.sh
  2094. X    ;;
  2095. esac
  2096. case "$0" in
  2097. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  2098. esac
  2099. echo "Extracting man/atob.$manext (with variable substitutions)"
  2100. X$rm -f atob.$manext
  2101. X$spitshell >atob.$manext <<!GROK!THIS!
  2102. X.so $mansrc/btoa.$manext
  2103. X!GROK!THIS!
  2104. chmod 444 atob.$manext
  2105. END_OF_FILE
  2106. if test 450 -ne `wc -c <'man/atob.SH'`; then
  2107.     echo shar: \"'man/atob.SH'\" unpacked with wrong size!
  2108. fi
  2109. # end of 'man/atob.SH'
  2110. fi
  2111. if test -f 'man/btoa.SH' -a "${1}" != "-c" ; then 
  2112.   echo shar: Will not clobber existing file \"'man/btoa.SH'\"
  2113. else
  2114. echo shar: Extracting \"'man/btoa.SH'\" \(1769 characters\)
  2115. sed "s/^X//" >'man/btoa.SH' <<'END_OF_FILE'
  2116. case $CONFIG in
  2117. X'')
  2118. X    if test ! -f config.sh; then
  2119. X    ln ../config.sh . || \
  2120. X    ln ../../config.sh . || \
  2121. X    ln ../../../config.sh . || \
  2122. X    (echo "Can't find config.sh."; exit 1)
  2123. X    fi 2>/dev/null
  2124. X    . config.sh
  2125. X    ;;
  2126. esac
  2127. case "$0" in
  2128. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  2129. esac
  2130. echo "Extracting man/btoa.$manext (with variable substitutions)"
  2131. X$rm -f btoa.$manext
  2132. X$spitshell >btoa.$manext <<!GROK!THIS!
  2133. X.TH BTOA $manext local
  2134. X''' @(#) Manual page for atob/btoa -- (c) ram August 1990
  2135. X'''
  2136. X''' $Id: btoa.SH,v 2.0.1.1 91/05/27 14:31:27 ram Exp $
  2137. X'''
  2138. X''' $Log:    btoa.SH,v $
  2139. X''' Revision 2.0.1.1  91/05/27  14:31:27  ram
  2140. X''' patch5: search for config.sh is now silent
  2141. X''' 
  2142. X''' Revision 2.0  91/02/19  15:50:22  ram
  2143. X''' Baseline for first official release.
  2144. X''' 
  2145. X'''
  2146. X.SH NAME
  2147. btoa, atob \- encode/decode binary to printable ASCII
  2148. X.SH SYNOPSIS
  2149. X.B btoa
  2150. X.br
  2151. X.B atob
  2152. X.SH DESCRIPTION
  2153. X.I Btoa
  2154. is a filter that reads anything from the standard input, and encodes it into
  2155. printable ASCII on the standard output.  It also attaches a header and checksum
  2156. information used by the reverse filter 
  2157. X.I atob 
  2158. to find the start of the data and to check integrity.
  2159. X.PP
  2160. X.I Atob
  2161. reads an encoded file, strips off any leading and
  2162. trailing lines added by mailers, and recreates a copy of the original file
  2163. on the standard output.
  2164. X.I Atob 
  2165. gives NO output (and exits with an error message) if its input is garbage or 
  2166. the checksums do not check.
  2167. X.PP
  2168. X.SH FEATURES
  2169. X.I Btoa
  2170. uses a compact base-85 encoding so that
  2171. X4 bytes are encoded into 5 characters (file is expanded by 25%).
  2172. As a special case, 32-bit zero is encoded as one character.  This encoding
  2173. produces less output than
  2174. X.IR uuencode "(1)."
  2175. X.SH AUTHOR
  2176. Paul Rutter
  2177. X.SH "SEE ALSO"
  2178. kit($manext), mail(1), uuencode(1)
  2179. X!GROK!THIS!
  2180. chmod 444 btoa.$manext
  2181. END_OF_FILE
  2182. if test 1769 -ne `wc -c <'man/btoa.SH'`; then
  2183.     echo shar: \"'man/btoa.SH'\" unpacked with wrong size!
  2184. fi
  2185. # end of 'man/btoa.SH'
  2186. fi
  2187. if test -f 'man/mailkit.SH' -a "${1}" != "-c" ; then 
  2188.   echo shar: Will not clobber existing file \"'man/mailkit.SH'\"
  2189. else
  2190. echo shar: Extracting \"'man/mailkit.SH'\" \(461 characters\)
  2191. sed "s/^X//" >'man/mailkit.SH' <<'END_OF_FILE'
  2192. case $CONFIG in
  2193. X'')
  2194. X    if test ! -f config.sh; then
  2195. X        ln ../config.sh . || \
  2196. X        ln ../../config.sh . || \
  2197. X        ln ../../../config.sh . || \
  2198. X        (echo "Can't find config.sh."; exit 1)
  2199. X    fi 2>/dev/null
  2200. X    . config.sh
  2201. X    ;;
  2202. esac
  2203. case "$0" in
  2204. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  2205. esac
  2206. echo "Extracting man/mailkit.$manext (with variable substitutions)"
  2207. X$rm -f mailkit.$manext
  2208. X$spitshell >mailkit.$manext <<!GROK!THIS!
  2209. X.so $mansrc/kit.$manext
  2210. X!GROK!THIS!
  2211. chmod 444 mailkit.$manext
  2212. END_OF_FILE
  2213. if test 461 -ne `wc -c <'man/mailkit.SH'`; then
  2214.     echo shar: \"'man/mailkit.SH'\" unpacked with wrong size!
  2215. fi
  2216. # end of 'man/mailkit.SH'
  2217. fi
  2218. if test -f 'man/unkit.SH' -a "${1}" != "-c" ; then 
  2219.   echo shar: Will not clobber existing file \"'man/unkit.SH'\"
  2220. else
  2221. echo shar: Extracting \"'man/unkit.SH'\" \(453 characters\)
  2222. sed "s/^X//" >'man/unkit.SH' <<'END_OF_FILE'
  2223. case $CONFIG in
  2224. X'')
  2225. X    if test ! -f config.sh; then
  2226. X        ln ../config.sh . || \
  2227. X        ln ../../config.sh . || \
  2228. X        ln ../../../config.sh . || \
  2229. X        (echo "Can't find config.sh."; exit 1)
  2230. X    fi 2>/dev/null
  2231. X    . config.sh
  2232. X    ;;
  2233. esac
  2234. case "$0" in
  2235. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  2236. esac
  2237. echo "Extracting man/unkit.$manext (with variable substitutions)"
  2238. X$rm -f unkit.$manext
  2239. X$spitshell >unkit.$manext <<!GROK!THIS!
  2240. X.so $mansrc/kit.$manext
  2241. X!GROK!THIS!
  2242. chmod 444 unkit.$manext
  2243. END_OF_FILE
  2244. if test 453 -ne `wc -c <'man/unkit.SH'`; then
  2245.     echo shar: \"'man/unkit.SH'\" unpacked with wrong size!
  2246. fi
  2247. # end of 'man/unkit.SH'
  2248. fi
  2249. if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  2250.   echo shar: Will not clobber existing file \"'patchlevel.h'\"
  2251. else
  2252. echo shar: Extracting \"'patchlevel.h'\" \(42 characters\)
  2253. sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
  2254. X#define VERSION 2.0
  2255. X#define PATCHLEVEL 10
  2256. END_OF_FILE
  2257. if test 42 -ne `wc -c <'patchlevel.h'`; then
  2258.     echo shar: \"'patchlevel.h'\" unpacked with wrong size!
  2259. fi
  2260. # end of 'patchlevel.h'
  2261. fi
  2262. echo shar: End of archive 1 \(of 4\).
  2263. cp /dev/null ark1isdone
  2264. MISSING=""
  2265. for I in 1 2 3 4 ; do
  2266.     if test ! -f ark${I}isdone ; then
  2267.     MISSING="${MISSING} ${I}"
  2268.     fi
  2269. done
  2270. if test "${MISSING}" = "" ; then
  2271.     echo You have unpacked all 4 archives.
  2272.     rm -f ark[1-9]isdone
  2273. else
  2274.     echo You still need to unpack the following archives:
  2275.     echo "        " ${MISSING}
  2276. fi
  2277. ##  End of shell archive.
  2278. exit 0
  2279.